﻿using CSRedis;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ongoal.Quotation.Redis
{
    /// <summary>
    /// Redis操作服务接口
    /// </summary>
    public interface IRedisProvider
    {
        /// <summary>
        /// 获取redis值
        /// </summary>
        /// <typeparam name="T">类型</typeparam>
        /// <param name="key">Key</param>
        /// <param name="name">配置名称</param>
        /// <returns></returns>
        T Get<T>(string key, string name = "");
        /// <summary>
        /// 获取redis字符串值
        /// </summary>
        /// <param name="key"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        string Get(string key, string name = "");
        /// <summary>
        /// 异步获取redis值
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        Task<T> GetAsync<T>(string key, string name = "");
        /// <summary>
        /// 异步获取redis字符
        /// </summary>
        /// <param name="key"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        Task<string> GetAsync(string key, string name = "");
        /// <summary>
        /// 设置缓存
        /// </summary>
        /// <param name="key">Key</param>
        /// <param name="value">值</param>
        /// <param name="expireSeconds">过期时间</param>
        /// <param name="name">名称</param>
        /// <returns></returns>
        bool Set(string key, object value, int expireSeconds = -1, string name = "");
        /// <summary>
        /// 异步设置缓存
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <param name="expireSeconds"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        Task<bool> SetAsync(string key, object value, int expireSeconds = -1, string name = "");

        //
        // 摘要:
        //     检查给定 key 是否存在
        //
        // 参数:
        //   key:
        //     不含prefix前辍
        bool Exists(string key, string name = "");
        //
        // 摘要:
        //     检查给定 key 是否存在
        //
        // 参数:
        //   key:
        //     不含prefix前辍
        Task<bool> ExistsAsync(string key, string name = "");
        //
        // 摘要:
        //     为给定 key 设置过期时间
        //
        // 参数:
        //   key:
        //     不含prefix前辍
        //
        //   seconds:
        //     过期秒数
        bool Expire(string key, int seconds, string name = "");
        //
        // 摘要:
        //     为给定 key 设置过期时间
        //
        // 参数:
        //   key:
        //     不含prefix前辍
        //
        //   expire:
        //     过期时间
        bool Expire(string key, TimeSpan expire, string name = "");
        //
        // 摘要:
        //     为给定 key 设置过期时间
        //
        // 参数:
        //   key:
        //     不含prefix前辍
        //
        //   seconds:
        //     过期秒数
        Task<bool> ExpireAsync(string key, int seconds, string name = "");
        //
        // 摘要:
        //     为给定 key 设置过期时间
        //
        // 参数:
        //   key:
        //     不含prefix前辍
        //
        //   expire:
        //     过期时间
        Task<bool> ExpireAsync(string key, TimeSpan expire, string name = "");
        //
        // 摘要:
        //     为给定 key 设置过期时间
        //
        // 参数:
        //   key:
        //     不含prefix前辍
        //
        //   expire:
        //     过期时间
        bool ExpireAt(string key, DateTime expire, string name = "");
        //
        // 摘要:
        //     为给定 key 设置过期时间
        //
        // 参数:
        //   key:
        //     不含prefix前辍
        //
        //   expire:
        //     过期时间
        Task<bool> ExpireAtAsync(string key, DateTime expire, string name = "");
        //
        // 摘要:
        //     缓存壳(哈希表) 
        //
        // 参数:
        //   key:
        //     不含prefix前辍
        //
        //   field:
        //     字段
        //
        //   timeoutSeconds:
        //     缓存秒数
        //
        //   getData:
        //     获取源数据的函数
        //
        // 类型参数:
        //   T:
        //     缓存类型
        T CacheShell<T>(string key, string field, int timeoutSeconds, SqlSugarClient db, Func<SqlSugarClient, T> getData, string name = "");
        //
        // 摘要:
        //     缓存壳
        //
        // 参数:
        //   key:
        //     不含prefix前辍
        //
        //   timeoutSeconds:
        //     缓存秒数
        //
        //   getData:
        //     获取源数据的函数
        //
        // 类型参数:
        //   T:
        //     缓存类型
        T CacheShell<T>(string key, int timeoutSeconds, SqlSugarClient db, Func<SqlSugarClient, T> getData, string name = "");
        Task<T> CacheShellAsync<T>(string key, string field, int timeoutSeconds, SqlSugarClient db, Func<SqlSugarClient, Task<T>> getDataAsync, string name = "");
        //
        // 摘要:
        //     缓存壳
        //
        // 参数:
        //   key:
        //     不含prefix前辍
        //
        //   timeoutSeconds:
        //     缓存秒数
        //
        //   getDataAsync:
        //     获取源数据的函数
        //
        // 类型参数:
        //   T:
        //     缓存类型
        Task<T> CacheShellAsync<T>(string key, int timeoutSeconds, SqlSugarClient db, Func<SqlSugarClient, Task<T>> getDataAsync, string name = "");
        //
        // 摘要:
        //     用于在 key 存在时删除 key
        //
        // 参数:
        //   key:
        //     不含prefix前辍
        long Del(string name = "", params string[] key);
        //
        // 摘要:
        //     用于在 key 存在时删除 key
        //
        // 参数:
        //   key:
        //     不含prefix前辍
        Task<long> DelAsync(string name = "", params string[] key);
        /// <summary>
        /// 分布式锁
        /// </summary>
        /// <param name="lockTimeout">锁时间 单位毫秒</param>
        /// <param name="lockkey">锁键</param>
        /// <param name="GetLockAction">获取锁方法</param>
        /// <param name="MissLockAction">未获取锁方法</param>
        /// <param name="name">reids客户端名称</param>
        void DistributedLock(long lockTimeout, string lockkey, Action GetLockAction, Action MissLockAction, string name = "");
        /// <summary>
        /// 分布式锁
        /// </summary>
        /// <param name="lockTimeout">锁时间 单位毫秒</param>
        /// <param name="lockkey">锁键</param>
        /// <param name="GetLockAction">获取锁方法</param>
        /// <param name="MissLockAction">未获取锁方法</param>
        /// <param name="name">reids客户端名称</param>
        /// <param name="actionparams">传入参数</param>
        void DistributedLock(long lockTimeout, string lockkey, Action<object[]> GetLockAction, Action<object[]> MissLockAction, string name = "", params object[] actionparams);
        /// <summary>
        /// 有返回带参数的分布式锁
        /// </summary>
        /// <param name="lockTimeout">锁时间 单位毫秒</param>
        /// <param name="lockkey">锁键</param>
        /// <param name="GetLockFunc">获取锁方法</param>
        /// <param name="MissLockFunc">未获取锁方法</param>
        /// <param name="name">reids客户端名称</param>
        /// <returns></returns>
        object DistributedLock(int lockTimeout, string lockkey, Func<object> GetLockFunc, Func<object> MissLockFunc, string name = "");
        /// <summary>
        /// 有返回带参数的分布式锁
        /// </summary>
        /// <param name="lockTimeout">锁时间 单位毫秒</param>
        /// <param name="lockkey">锁键</param>
        /// <param name="GetLockFunc">获取锁方法</param>
        /// <param name="MissLockFunc">未获取锁方法</param>
        /// <param name="name">reids客户端名称</param>
        /// <param name="funcParams">传入参数</param>
        /// <returns></returns>
        object DistributedLock(int lockTimeout, string lockkey, Func<object[], object> GetLockFunc, Func<object[], object> MissLockFunc, string name = "", params object[] funcParams);
        /// <summary>
        /// 获取多个指定 key 的值(数组)
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="keys">键值数组</param>
        /// <param name="name">Redis配置名称</param>
        /// <returns></returns>
        T[] MGet<T>(string name = "", params string[] keys);
        /// <summary>
        /// 获取多个指定 key 的值(数组)
        /// </summary>
        /// <param name="name">键值数组</param>
        /// <param name="keys">Redis配置名称</param>
        /// <returns></returns>
        string[] MGet(string name = "", params string[] keys);
        /// <summary>
        /// 获取多个指定 key 的值(数组)
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="name">Redis配置名称</param>
        /// <param name="keys">键值数组</param>
        /// <returns></returns>
        Task<T[]> MGetAsync<T>(string name = "", params string[] keys);
        /// <summary>
        /// 获取多个指定 key 的值(数组)
        /// </summary>
        /// <param name="name">Redis配置名称</param>
        /// <param name="keys">键值数组</param>
        /// <returns></returns>
        Task<string[]> MGetAsync(string name = "", params string[] keys);
        /// <summary>
        /// 同时设置一个或多个 key-value 对
        /// </summary>
        /// <param name="name"></param>
        /// <param name="keyValues"></param>
        /// <returns></returns>
        bool MSet(string name = "", params object[] keyValues);
        /// <summary>
        /// 同时设置一个或多个 key-value 对
        /// </summary>
        /// <param name="name"></param>
        /// <param name="keyValues"></param>
        /// <returns></returns>
        Task<bool> MSetAsync(string name = "", params object[] keyValues);
        /// <summary>
        /// 同时设置一个或多个 key-value 对，当且仅当所有给定 key 都不存在
        /// </summary>
        /// <param name="name"></param>
        /// <param name="keyValues"></param>
        /// <returns></returns>
        bool MSetNx(string name = "", params object[] keyValues);
        /// <summary>
        /// 同时设置一个或多个 key-value 对，当且仅当所有给定 key 都不存在
        /// </summary>
        /// <param name="name"></param>
        /// <param name="keyValues"></param>
        /// <returns></returns>
        Task<bool> MSetNxAsync(string name = "", params object[] keyValues);
        /// <summary>
        /// 有在 key 不存在时设置 key 的值
        /// </summary>
        /// <param name="key">键</param>
        /// <param name="value">值</param>
        /// <param name="name">Redis配置名称</param>
        /// <returns></returns>
        bool SetNx(string key, object value, string name = "");
        /// <summary>
        /// 有在 key 不存在时设置 key 的值
        /// </summary>
        /// <param name="key">键</param>
        /// <param name="value">值</param>
        /// <param name="name">Redis配置名称</param>
        /// <returns></returns>
        Task<bool> SetNxAsync(string key, object value, string name = "");
        /// <summary>
        /// 创建管道传输，注意：官方集群时请务必预热slotCache，否则会产生moved错误
        /// </summary>
        /// <param name="handler"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        object[] StartPipe(Action<CSRedisClientPipe<string>> handler, string name = "");
        /// <summary>
        /// 创建管道传输，注意：官方集群时请务必预热slotCache，否则会产生moved错误，打包提交如：RedisHelper.StartPipe().Set("a",  "1").HSet("b", "f", "2").EndPipe();
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        CSRedisClientPipe<string> StartPipe(string name = "");
        /// <summary>
        /// 将一个或多个值插入到列表头部 
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="name"></param>
        /// <param name="key">Key键</param>
        /// <param name="value"></param>
        /// <returns></returns>
        long LPush<T>(string key, string name = "", params T[] value);
        /// <summary>
        /// 将一个或多个值插入到列表头部 
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="name"></param>
        /// <param name="key">Key键</param>
        /// <param name="value"></param>
        /// <returns></returns>
        Task<long> LPushAsync<T>(string key, string name = "", params T[] value);

        T RPop<T>(string key, string name = "");
        /// <summary>
        /// 从尾部取值
        /// </summary>
        /// <param name="key"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        string RPop(string key, string name = "");
        Task<T> RPopAsync<T>(string key, string name = "");
        /// <summary>
        /// 
        /// </summary>
        /// <param name="key"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        Task<string> RPopAsync(string key, string name = "");
        /// <summary>
        /// 将哈希表 key 中的字段 field 的值设为 value
        /// </summary>
        /// <param name="key">键</param>
        /// <param name="field">字段</param>
        /// <param name="value">值</param>
        /// <param name="name">配置名称</param>
        /// <returns></returns>
        bool HSet(string key, string field, object value, string name = "");
        /// <summary>
        /// 将哈希表 key 中的字段 field 的值设为 value
        /// </summary>
        /// <param name="key">键</param>
        /// <param name="field">字段</param>
        /// <param name="value">值</param>
        /// <param name="name">配置名称</param>
        /// <returns></returns>
        Task<bool> HSetAsync(string key, string field, object value, string name = "");
        /// <summary>
        /// 获取存储在哈希表中指定字段的值
        /// </summary>
        /// <typeparam name="T">类型</typeparam>
        /// <param name="key">键</param>
        /// <param name="field">字段</param>
        /// <param name="name">配置名称</param>
        /// <returns></returns>
        T HGet<T>(string key, string field, string name = "");
        /// <summary>
        /// 获取存储在哈希表中指定字段的值
        /// </summary>
        /// <param name="key">键</param>
        /// <param name="field">字段</param>
        /// <param name="name">配置名称</param>
        /// <returns></returns>
        string HGet(string key, string field, string name = "");
        /// <summary>
        /// 获取存储在哈希表中指定字段的值
        /// </summary>
        /// <param name="key"></param>
        /// <param name="field"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        Task<string> HGetAsync(string key, string field, string name = "");
        /// <summary>
        /// 获取存储在哈希表中指定字段的值
        /// </summary>
        /// <typeparam name="T">类型</typeparam>
        /// <param name="key">键</param>
        /// <param name="field">字段</param>
        /// <param name="name">配置名称</param>
        /// <returns></returns>
        Task<T> HGetAsync<T>(string key, string field, string name = "");
        /// <summary>
        /// 获取在哈希表中指定 key 的所有字段和值
        /// </summary>
        /// <param name="key">键</param>
        /// <param name="name">配置名称</param>
        /// <returns></returns>
        Dictionary<string, string> HGetAll(string key, string name = "");
        /// <summary>
        /// 获取在哈希表中指定 key 的所有字段和值
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key">键</param>
        /// <param name="name">配置名称</param>
        /// <returns></returns>
        Dictionary<string, T> HGetAll<T>(string key, string name = "");
        /// <summary>
        /// 获取在哈希表中指定 key 的所有字段和值
        /// </summary>
        /// <param name="key">键</param>
        /// <param name="name">配置名称</param>
        /// <returns></returns>
        Task<Dictionary<string, string>> HGetAllAsync(string key, string name = "");
        /// <summary>
        /// 获取在哈希表中指定 key 的所有字段和值
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key">键</param>
        /// <param name="name">配置名称</param>
        /// <returns></returns>
        Task<Dictionary<string, T>> HGetAllAsync<T>(string key, string name = "");
        /// <summary>
        /// 删除一个或多个哈希表字段
        /// </summary>
        /// <param name="key">键</param>
        /// <param name="name">配置名称</param>
        /// <param name="fields"></param>
        /// <returns></returns>
        long HDel(string key, string name = "", params string[] fields);
        /// <summary>
        /// 删除一个或多个哈希表字段
        /// </summary>
        /// <param name="key">键</param>
        /// <param name="name">配置名称</param>
        /// <param name="fields"></param>
        /// <returns></returns>
        Task<long> HDelAsync(string key, string name = "", params string[] fields);
        /// <summary>
        /// 查看哈希表 key 中，指定的字段是否存在
        /// </summary>
        /// <param name="key">键</param>
        /// <param name="field">字段</param>
        /// <param name="name">配置名称</param>
        /// <returns></returns>
        bool HExists(string key, string field, string name = "");
        /// <summary>
        /// 查看哈希表 key 中，指定的字段是否存在
        /// </summary>
        /// <param name="key">键</param>
        /// <param name="field">字段</param>
        /// <param name="name">配置名称</param>
        /// <returns></returns>
        Task<bool> HExistsAsync(string key, string field, string name = "");
        /// <summary>
        /// 向集合添加一个或多个成员
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key">键</param>
        /// <param name="name">配置名称</param>
        /// <param name="members">一个或多个成员</param>
        /// <returns></returns>
        long SAdd<T>(string key, string name = "", params T[] members);
        /// <summary>
        /// 向集合添加一个或多个成员
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key">键</param>
        /// <param name="name">配置名称</param>
        /// <param name="members">一个或多个成员</param>
        /// <returns></returns>
        Task<long> SAddAsync<T>(string key, string name = "", params T[] members);
        /// <summary>
        /// 获取所有哈希表中的字段
        /// </summary>
        /// <param name="key">键</param>
        /// <param name="name">配置名称</param>
        /// <returns></returns>
        string[] HKeys(string key, string name = "");
        /// <summary>
        /// 获取所有哈希表中的字段
        /// </summary>
        /// <param name="key">键</param>
        /// <param name="name">配置名称</param>
        /// <returns></returns>
        Task<string[]> HKeysAsync(string key, string name = "");
        /// <summary>
        /// 获取哈希表中字段的数量
        /// </summary>
        /// <param name="key">键</param>
        /// <param name="name">配置名称</param>
        /// <returns></returns>
        long HLen(string key, string name = "");
        /// <summary>
        /// 获取哈希表中字段的数量
        /// </summary>
        /// <param name="key">键</param>
        /// <param name="name">配置名称</param>
        /// <returns></returns>
        Task<long> HLenAsync(string key, string name = "");
        /// <summary>
        /// 获取存储在哈希表中多个字段的值
        /// </summary>
        /// <param name="key">键</param>
        /// <param name="name">配置名称</param>
        /// <param name="fields">字段</param>
        /// <returns></returns>
        string[] HMGet(string key, string name = "", params string[] fields);
        /// <summary>
        /// 获取存储在哈希表中多个字段的值
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key">键</param>
        /// <param name="name">配置名称</param>
        /// <param name="fields">字段</param>
        /// <returns></returns>
        T[] HMGet<T>(string key, string name = "", params string[] fields);
        /// <summary>
        /// 同时将多个 field-value (域-值)对设置到哈希表 key 中 
        /// </summary>
        /// <param name="key">键</param>
        /// <param name="name">配置名称</param>
        /// <param name="keyValues"> key1 value1 [key2 value2]  new[] { "F1", "string", "F2", "true", "F3", DateTime.Now.ToString() }</param>
        /// <returns></returns>
        bool HMSet(string key, string name = "", params object[] keyValues);
        /// <summary>
        /// 同时将多个 field-value (域-值)对设置到哈希表 key 中
        /// </summary>
        /// <param name="key">键</param>
        /// <param name="name">配置名称</param>
        /// <param name="keyValues"> key1 value1 [key2 value2]</param>
        /// <returns></returns>
        Task<bool> HMSetAsync(string key, string name = "", params object[] keyValues);
        /// <summary>
        /// 获取Redis客服端
        /// </summary>
        /// <param name="name">配置名称</param>
        /// <returns></returns>
        CSRedisClient GetClient(string name);

        /// <summary>
        /// 返回集合中的所有成员
        /// </summary>
        /// <typeparam name="T">byte[] 或其他类型</typeparam>
        /// <param name="key">键</param>
        /// <param name="name">客户端配置名称，为空为默认缓存</param>
        /// <returns></returns>
        T[] SMembers<T>(string key, string name = "");
        /// <summary>
        /// 返回集合中的所有成员
        /// </summary>
        /// <param name="key">键</param>
        /// <param name="name">客户端配置名称，为空为默认缓存</param>
        /// <returns></returns>
        string[] SMembers(string key, string name = "");
        /// <summary>
        /// 返回集合中的所有成员
        /// </summary>
        /// <param name="key">键</param>
        /// <param name="name">客户端配置名称，为空为默认缓存</param>
        /// <returns></returns>
        Task<string[]> SMembersAsync(string key, string name = "");
        /// <summary>
        /// 返回集合中的所有成员
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key">键</param>
        /// <param name="name">客户端配置名称，为空为默认缓存</param>
        /// <returns></returns>
        Task<T[]> SMembersAsync<T>(string key, string name = "");
        /// <summary>
        /// 移除集合中一个或多个成员
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="name">客户端配置名称，为空为默认缓存</param>
        /// <param name="key">键</</param>
        /// <param name="members">一个或多个成员</param>
        /// <returns></returns>
        long SRem<T>(string name, string key, params T[] members);
        /// <summary>
        /// 移除集合中一个或多个成员
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="name">客户端配置名称，为空为默认缓存</param>
        /// <param name="key">键</param>
        /// <param name="members">一个或多个成员</param>
        /// <returns></returns>
        Task<long> SRemAsync<T>(string name, string key, params T[] members);
        /// <summary>
        ///  判断 member 元素是否是集合 key 的成员
        /// </summary>
        /// <param name="key">键</param>
        /// <param name="member">成员</param>
        /// <param name="name">客户端配置名称，为空为默认缓存</param>
        /// <returns></returns>
        bool SIsMember(string key, object member, string name = "");
        /// <summary>
        ///  判断 member 元素是否是集合 key 的成员
        /// </summary>
        /// <param name="key">键</param>
        /// <param name="member">成员</param>
        /// <param name="name">客户端配置名称，为空为默认缓存</param>
        /// <returns></returns>
        Task<bool> SIsMemberAsync(string key, object member, string name = "");
        /// <summary>
        /// 返回给定所有集合的差集
        /// </summary>
        /// <param name="name">客户端配置名称，为空为默认缓存</param>
        /// <param name="keys">键集合</param>
        /// <returns></returns>
        string[] SDiff(string name, params string[] keys);
        /// <summary>
        /// 返回给定所有集合的差集
        /// </summary>
        /// <typeparam name="T"> byte[] 或其他类型</typeparam>
        /// <param name="name">客户端配置名称，为空为默认缓存</param>
        /// <param name="keys">键集合</param>
        /// <returns></returns>
        T[] SDiff<T>(string name, params string[] keys);
        /// <summary>
        /// 返回给定所有集合的差集
        /// </summary>
        /// <typeparam name="T">byte[] 或其他类型</typeparam>
        /// <param name="name">客户端配置名称，为空为默认缓存</param>
        /// <param name="keys">键集合</param>
        /// <returns></returns>
        Task<T[]> SDiffAsync<T>(string name, params string[] keys);

        /// <summary>
        /// 返回给定所有集合的差集
        /// </summary>
        /// <param name="name">客户端配置名称，为空为默认缓存</param>
        /// <param name="keys">键集合</param>
        /// <returns></returns>
        Task<string[]> SDiffAsync(string name, params string[] keys);

        /// <summary>
        /// 返回给定所有集合的交集
        /// </summary>
        /// <param name="name">客户端配置名称，为空为默认缓存</param>
        /// <param name="keys">键集合</param>
        /// <returns></returns>
        string[] SInter(string name, params string[] keys);
        /// <summary>
        /// 返回给定所有集合的交集
        /// </summary>
        /// <typeparam name="T">byte[] 或其他类型</typeparam>
        /// <param name="name">客户端配置名称，为空为默认缓存</param>
        /// <param name="keys">键集合</param>
        /// <returns></returns>
        T[] SInter<T>(string name, params string[] keys);
        /// <summary>
        /// 返回给定所有集合的交集
        /// </summary>
        /// <typeparam name="T">byte[] 或其他类型</typeparam>
        /// <param name="name">客户端配置名称，为空为默认缓存</param>
        /// <param name="keys">键集合</param>
        /// <returns></returns>
        Task<T[]> SInterAsync<T>(string name, params string[] keys);
        /// <summary>
        /// 返回给定所有集合的交集
        /// </summary>
        /// <param name="name">客户端配置名称，为空为默认缓存</param>
        /// <param name="keys">键集合</param>
        /// <returns></returns>
        Task<string[]> SInterAsync(string name, params string[] keys);

        /// <summary>
        /// 返回所有给定集合的并集
        /// </summary>
        /// <typeparam name="T">byte[] 或其他类型</typeparam>
        /// <param name="keys">键集合</param>
        /// <returns></returns>
        T[] SUnion<T>(string name, params string[] keys);
        /// <summary>
        /// 返回所有给定集合的并集
        /// </summary>
        /// <param name="keys">键集合</param>
        /// <returns></returns>
        string[] SUnion(string name, params string[] keys);
        /// <summary>
        /// 返回所有给定集合的并集
        /// </summary>
        /// <typeparam name="T">byte[] 或其他类型</typeparam>
        /// <param name="name">客户端配置名称，为空为默认缓存</param>
        /// <param name="keys">键集合</param>
        /// <returns></returns>
        Task<T[]> SUnionAsync<T>(string name, params string[] keys);
        /// <summary>
        /// 返回所有给定集合的并集
        /// </summary>
        /// <param name="name">客户端配置名称，为空为默认缓存</param>
        /// <param name="keys">键集合</param>
        /// <returns></returns>
        Task<string[]> SUnionAsync(string name, params string[] keys);
        /// <summary>
        /// 向有序集合添加一个或多个成员，或者更新已存在成员的分数
        /// </summary>
        /// <param name="name">客户端配置名称，为空为默认缓存</param>
        /// <param name="key">键</param>
        /// <param name="scoreMembers">一个或多个成员分数</param>
        /// <returns></returns>
        long ZAdd(string name, string key, params (decimal, object)[] scoreMembers);
        /// <summary>
        ///  向有序集合添加一个或多个成员，或者更新已存在成员的分数
        /// </summary>
        /// <param name="name">客户端配置名称，为空为默认缓存</param>
        /// <param name="key">键</param>
        /// <param name="scoreMembers">一个或多个成员分数</param>
        /// <returns></returns>
        Task<long> ZAddAsync(string name, string key, params (decimal, object)[] scoreMembers);

        /// <summary>
        /// 获取有序集合的成员数量
        /// </summary>
        /// <param name="key">键</param>
        /// <param name="name">客户端配置名称，为空为默认缓存</param>
        /// <returns></returns>
        long ZCard(string key, string name = "");
        /// <summary>
        /// 获取有序集合的成员数量
        /// </summary>
        /// <param name="key">键</param>
        /// <param name="name">客户端配置名称，为空为默认缓存</param>
        /// <returns></returns>
        Task<long> ZCardAsync(string key, string name = "");
        /// <summary>
        /// 通过分数返回有序集合指定区间内的成员
        /// </summary>
        /// <param name="key">键</param>
        /// <param name="min">分数最小值 decimal.MinValue 1</param>
        /// <param name="max">分数最大值 decimal.MaxValue 10</param>
        /// <param name="count">返回多少成员</param>
        /// <param name="offset">返回条件偏移位置</param>
        /// <param name="name">客户端配置名称，为空为默认缓存</param>
        /// <returns></returns>
        string[] ZRangeByScore(string key, decimal min, decimal max, long? count = null, long offset = 0, string name = "");
        /// <summary>
        /// 通过分数返回有序集合指定区间内的成员
        /// </summary>
        /// <typeparam name="T">byte[] 或其他类型</typeparam>
        /// <param name="key"></param>
        /// <param name="min">分数最小值 decimal.MinValue 1</param>
        /// <param name="max">分数最大值 decimal.MaxValue 10</param>
        /// <param name="count">返回多少成员</param>
        /// <param name="offset"> 返回条件偏移位置</param>
        /// <param name="name">客户端配置名称，为空为默认缓存</param>
        /// <returns></returns>
        T[] ZRangeByScore<T>(string key, decimal min, decimal max, long? count = null, long offset = 0, string name = "");
        /// <summary>
        /// 通过分数返回有序集合指定区间内的成员
        /// </summary>
        /// <param name="key">不含prefix前辍</param>
        /// <param name="min"> 分数最小值 -inf (1 1</param>
        /// <param name="max">分数最大值 +inf (10 10</param>
        /// <param name="count">返回多少成员</param>
        /// <param name="offset">返回条件偏移位置</param>
        /// <param name="name">客户端配置名称，为空为默认缓存</param>
        /// <returns></returns>
        string[] ZRangeByScore(string key, string min, string max, long? count = null, long offset = 0, string name = "");
        /// <summary>
        /// 通过分数返回有序集合指定区间内的成员
        /// </summary>
        /// <typeparam name="T">byte[] 或其他类型</typeparam>
        /// <param name="key">不含prefix前辍</param>
        /// <param name="min">分数最小值 -inf (1 1</param>
        /// <param name="max">分数最大值 +inf (10 10</param>
        /// <param name="count"> 返回多少成员</param>
        /// <param name="offset">返回条件偏移位置</param>
        /// <param name="name">客户端配置名称，为空为默认缓存</param>
        /// <returns></returns>
        T[] ZRangeByScore<T>(string key, string min, string max, long? count = null, long offset = 0, string name = "");
        /// <summary>
        /// 通过分数返回有序集合指定区间内的成员
        /// </summary>
        /// <param name="key">不含prefix前辍</param>
        /// <param name="min">分数最小值 decimal.MinValue 1</param>
        /// <param name="max">分数最大值 decimal.MaxValue 10</param>
        /// <param name="count">返回多少成员</param>
        /// <param name="offset">返回条件偏移位置</param>
        /// <param name="name">客户端配置名称，为空为默认缓存</param>
        /// <returns></returns>
        Task<string[]> ZRangeByScoreAsync(string key, decimal min, decimal max, long? count = null, long offset = 0, string name = "");
        /// <summary>
        /// 通过分数返回有序集合指定区间内的成员
        /// </summary>
        /// <typeparam name="T">byte[] 或其他类型</typeparam>
        /// <param name="key">键</param>
        /// <param name="min"> 分数最小值 decimal.MinValue 1</param>
        /// <param name="max">分数最大值 decimal.MaxValue 10</param>
        /// <param name="count">返回多少成员</param>
        /// <param name="offset">返回条件偏移位置</param>
        /// <param name="name">客户端配置名称，为空为默认缓存</param>
        /// <returns></returns>
        Task<T[]> ZRangeByScoreAsync<T>(string key, decimal min, decimal max, long? count = null, long offset = 0, string name = "");

        /// <summary>
        /// 通过索引区间返回有序集合成指定区间内的成员和分数
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key">键</param>
        /// <param name="start">开始位置，0表示第一个元素，-1表示最后一个元素</param>
        /// <param name="stop"> 结束位置，0表示第一个元素，-1表示最后一个元素</param>
        /// <param name="name">客户端配置名称，为空为默认缓存</param>
        /// <returns></returns>
        (T member, decimal score)[] ZRangeWithScores<T>(string key, long start, long stop, string name = "");
        /// <summary>
        /// 通过索引区间返回有序集合成指定区间内的成员和分数
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key">键</param>
        /// <param name="start">开始位置，0表示第一个元素，-1表示最后一个元素</param>
        /// <param name="stop"> 结束位置，0表示第一个元素，-1表示最后一个元素</param>
        /// <param name="name">客户端配置名称，为空为默认缓存</param>
        /// <returns></returns>
        (string member, decimal score)[] ZRangeWithScores(string key, long start, long stop, string name = "");
        /// <summary>
        /// 通过索引区间返回有序集合成指定区间内的成员和分数
        /// </summary>
        /// <typeparam name="T">byte[] 或其他类型</typeparam>
        /// <param name="key"></param>
        /// <param name="start">开始位置，0表示第一个元素，-1表示最后一个元素</param>
        /// <param name="stop">结束位置，0表示第一个元素，-1表示最后一个元素</param>
        /// <param name="name">客户端配置名称，为空为默认缓存</param>
        /// <returns></returns>
        Task<(T member, decimal score)[]> ZRangeWithScoresAsync<T>(string key, long start, long stop, string name = "");
        /// <summary>
        /// 通过索引区间返回有序集合成指定区间内的成员和分数
        /// </summary>
        /// <param name="key">键</param>
        /// <param name="start"> 开始位置，0表示第一个元素，-1表示最后一个元素</param>
        /// <param name="stop">结束位置，0表示第一个元素，-1表示最后一个元素</param>
        /// <param name="name">客户端配置名称，为空为默认缓存</param>
        /// <returns></returns>
        Task<(string member, decimal score)[]> ZRangeWithScoresAsync(string key, long start, long stop, string name = "");
        /// <summary>
        /// 移除有序集合中的一个或多个成员
        /// </summary>
        /// <typeparam name="T">byte[] 或其他类型</typeparam>
        /// <param name="name">客户端配置名称，为空为默认缓存</param>
        /// <param name="key">键</param>
        /// <param name="member">一个或多个成员</param>
        /// <returns></returns>
        long ZRem<T>(string name, string key, params T[] member);
        /// <summary>
        /// 移除有序集合中的一个或多个成员
        /// </summary>
        /// <typeparam name="T">byte[] 或其他类型</typeparam>
        /// <param name="name">客户端配置名称，为空为默认缓存</param>
        /// <param name="key">键</param>
        /// <param name="member">一个或多个成员</param>
        /// <returns></returns>
        Task<long> ZRemAsync<T>(string name, string key, params T[] member);
        /// <summary>
        /// 保存主从关系型缓存
        /// </summary>
        /// <param name="miankey">主键</param>
        /// <param name="Detailkey">详细键</param>
        /// <param name="value">值</param>
        /// <param name="expireSeconds">过期时间</param>
        /// <param name="name"></param>
        /// <returns></returns>
        bool SetReliashObject(string miankey, string Detailkey, object value, int expireSeconds = -1, string name = "");
        /// <summary>
        /// 保存主从关系型缓存
        /// </summary>
        /// <param name="miankey">主键</param>
        /// <param name="values">值集合</param>
        /// <param name="expireSeconds"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        bool SetReliashObject(string miankey, Dictionary<string, object> values, int expireSeconds = -1, string name = "");
        /// <summary>
        /// 删除主从关系型缓存
        /// </summary>
        /// <param name="Miankey"></param>
        /// <param name="Detailkey"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        bool DetReliashObject(string Miankey, string Detailkey, string name = "");
        /// <summary>
        /// 获取所有主从关系型缓存
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="mainkey"></param>
        /// <param name="name">客户端配置名称，为空为默认缓存</param>
        /// <returns></returns>
        T[] GetReliashObjectAll<T>(string mainkey, string name = "");

        /// <summary>
        /// 分页获取主从关系型缓存
        /// </summary>
        /// <typeparam name="T">byte[] 或其他类型</typeparam>
        /// <param name="mainkey">主表键</param>
        /// <param name="pageindex">当前页</param>
        /// <param name="PageSize">页记录数</param>
        ///<param name="name">客户端配置名称，为空为默认缓存</param>
        /// <returns></returns>
        T[] GetReliashObjectPage<T>(string mainkey, int pageindex, int PageSize, string name = "");


    }

}
